<template>
  <div class="panel-container">
    <div class="panel-content content-2">
      <div class="panel-title">{{ title }}</div>
      <el-table stripe :data="dataList" size="mini" :header-cell-style="{ background: '#F5F5F5', color: '#000000' }" ref="table1" style="width: 100%" v-loading="dataListLoading">
        <el-table-column align="center" header-align="center" prop="vip_id" label="会员ID"> </el-table-column>
        <el-table-column align="center" header-align="center" prop="vip_level" label="会员等级"> </el-table-column>
        <el-table-column align="center" header-align="center" prop="push_num" label="30天内收到的推送数量"> </el-table-column>
        <el-table-column align="center" header-align="center" prop="days" label="连续未推送天数"> </el-table-column>
        <el-table-column align="left" header-align="center" prop="cate_arr" label="回收标签" width="300">
          <template slot-scope="scope">
            <div class="tag-list">
              <el-tag v-for="item in scope.row.cate_arr" :key="item.code">{{ item.name }}:{{ item.score }}</el-tag>
            </div>
          </template>
        </el-table-column>
        <el-table-column align="left" header-align="center" prop="city_arr" label="区域标签" width="300">
          <template slot-scope="scope">
            <div class="tag-list">
              <el-tag type="warning" v-for="item in scope.row.city_arr" :key="item.code">{{ item.name }}:{{ item.socre }}</el-tag>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        small
        background
        :current-page="pageNumber"
        :page-size="pageSize"
        :page-sizes="[10, 20, 50, 100]"
        :total="pageTotal"
        @current-change="currentChangeHandle"
        @size-change="sizeChangeHandle"
        layout="total, sizes, prev, pager, next, jumper"
        style="margin-top: 20px; text-align: right"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import { apiBusinessNoPushVipArr } from '@/api/dataStatistics'

export default {
  name: 'Panel2',
  props: {
    title: String,
  },
  data() {
    return {
      dataList: [],
      pageNumber: 1,
      pageSize: 10,
      pageTotal: 0,
      dataListLoading: false,
    }
  },
  activated() {
    this.$refs.table1.doLayout()
  },
  mounted() {
    this.getDataList()
  },
  destroyed() {},
  methods: {
    getDataList() {
      this.dataListLoading = true
      apiBusinessNoPushVipArr({ pageNumber: this.pageNumber, pageSize: this.pageSize })
        .then((res) => {
          const { data, total } = res
          this.dataListLoading = false
          this.dataList = data
          this.pageTotal = total
        })
        .catch((e) => {
          this.dataList = []
          this.pageTotal = 0
          this.dataListLoading = false
        })
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageNumber = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageNumber = val
      this.getDataList()
    },
  },
}
</script>

<style scoped lang="scss">
.text-1 {
  margin-top: 20px;
  text-align: right;
  .label {
    display: inline-block;
    width: 200px;
    text-align: center;
  }
  .num {
    display: inline-block;
    width: 200px;
    text-align: center;
  }
}

.el-tag {
  margin-right: 4px;
  margin-bottom: 6px;
}
</style>
